package io.jee.runshan.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class SpringHolder implements ApplicationContextAware {
	private static ApplicationContext context;

	public void setApplicationContext(ApplicationContext acx) {
		context = acx;
	}

	public static ApplicationContext getApplicationContext() {
		return context;
	}

	public static <T> T getBean(String name, Class<T> clz) {
		return context.getBean(name, clz);
	}

	public static Object getBean(String name) {
		return context.getBean(name);
	}

	public static <T> T getBean(Class<T> clz) {
		return context.getBean(clz);
	}

	public static Object getBean(String name, Object... obj) {
		return context.getBean(name, obj);
	}

	public static <T> T getBean(Class<T> clz, Object... obj) {
		return context.getBean(clz, obj);
	}

}
